PATH![]() |
![]() ![]() |
Your goal in positioning a window on the desktop is to place it where the user expects it. For a new document, this usually means just below and to the right of the last document window in which the user was working. For a saved document, it usually means the location of the document window when the document was last saved (if it was saved on a computer with the same screen configuration).
On Macintosh computers with a single screen of known size, positioning windows is fairly straightforward. You position the first new document window on the upper-left corner of the desktop. Open each additional new document window with its upper-left corner slightly below and to the right of the upper-left corner of its predecessor.
On computers with multiple monitors, window placement depends on a number of factors:
In general, you place the first new document window on the main screen, and you place subsequent document windows on the screen that contains the largest portion of the most recently active document window. That is, if you display a blank document window when the user starts up your application, you place the window on the main screen. If the user moves the window to another screen and then creates another new document, you place the new document window on the other screen. Although the user is free to place windows so that they cross screen boundaries, you should never display a new window that spans multiple screens.
When the user opens a saved document, you replicate the size and location of the window in which the document was last saved, if possible.
The Window Manager recognizes a set of positioning constants--which you supply in the extended window ( 'wind' ) resource or via the function RepositionWindow --that let you position new windows automatically. You typically use the constant kWindowCascadeOnParentWindowScreen for positioning document windows. The kWindowCascadeOnParentWindowScreen constant specifies the basic guidelines for document window placement: The Window Manager places the first window in the upper-left corner of the main screen. It places subsequent windows with their upper-left corners below and to the right of the upper-left corner of the last window in which the user was working. The exact amount of pixels that the subsequent windows are shifted depends upon the current appearance.
If the user moves or closes a window that occupies one of the interim positions, and the window template specifies kWindowCascadeOnParentWindowScreen , the Window Manager uses the "empty" slot for the next new window created before moving further down and to the right.
For a complete list of the positioning constants and their effects, See RepositionWindow Constants.